<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<script src="./js/index.js"></script>
<script>
  // let p = new MyPromise((resolve, reject) => {
  //   resolve('解决1')
  // })
  //
  // let p1 = p.then(value => {
  //   return p1
  // })
  
  // MyPromise.resolve(
  //   new MyPromise((resolve,reject)=>{
  //     reject('fff')
  //   })
  // ).then(value => {
  //   console.log(value)
  // },reason => {
  //   console.log(reason)
  // })
  
  
  // MyPromise.reject(
  //   new MyPromise((resolve,reject) => {
  //     resolve('fggg')
  //   })
  // ).then(value=>{
  //   console.log(value)
  // },reason => {
  //   console.log(reason)
  // })
  
  let p1 = new MyPromise((resolve,reject) => {
    setTimeout(()=>{
      resolve('aaa')
    },1000)
  })
  let p2 = new MyPromise((resolve,reject) => {
    setTimeout(()=>{
      resolve('bbb')
    },2000)
  })
  
  // MyPromise.all([p1,p2]).then(value=>{
  //   console.log(value)
  // },reason => {
  //   console.log(reason)
  // })
  
  MyPromise.race([p1,p2]).then(value => {
    console.log(value)
  },reason => {
    console.log(reason)
  })
  
  
  
  
  
  
  // let p = new Promise((resolve, reject) => {
  //   resolve('aa')
  // })
  //
  // //TypeError: Chaining cycle detected for promise #<Promise>
  // let p2 = p.then(value => {
  //   return p2
  // })
  

</script>

</body>
</html>
